﻿namespace MvvmUtils.ViewModels
{
    public abstract class Handler
    {
        public abstract void Handle(Message message, IProperty property);

        public abstract void OnPropertyChanged(IProperty changedProperty);
    }

    public abstract class Handler<TMessage>
        where TMessage : Message
    {
        public void Handle(Message message, IProperty property)
        {
            var castedMessage = message as TMessage;
            if (castedMessage != null)
            {
                this.HandleInternal(castedMessage, property);
            }
        }

        protected abstract void HandleInternal(TMessage castedMessage, IProperty property);
    }
}
